﻿@model WebApp.Models.Notification
@{  ViewBag.Title = "消息通知 | Edit";} 
<!-- MAIN CONTENT -->
<div id="content">
     <!-- quick navigation bar -->
     <div class="row">
        <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
            <h1 class="page-title txt-color-blueDark">
                <i class="fa fa-table fa-fw "></i>
                路径
                <span>
                    >
                    消息通知
                </span>
            </h1>
        </div>
        <div class="col-xs-12 col-sm-5 col-md-5 col-lg-8">

        </div>
     </div>
    <!-- widget grid -->
    <section id="widget-grid" class="">
        <!-- row -->
        <div class="row">
     <!-- NEW WIDGET START -->
    <article class="col-sm-12 col-md-12 col-lg-12">

        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget" id="wid-id-1" data-widget-editbutton="false" data-widget-deletebutton="false">
            <!-- widget options:
            usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">
            data-widget-colorbutton="false"
            data-widget-editbutton="false"
            data-widget-togglebutton="false"
            data-widget-deletebutton="false"
            data-widget-fullscreenbutton="false"
            data-widget-custombutton="false"
            data-widget-collapsed="true"
            data-widget-sortable="false"
            -->
            <header>
                <span class="widget-icon"> <i class="fa fa-edit"></i> </span>
                <h2> 消息通知 </h2>

            </header>

            <!-- widget div-->
            <div>

                <!-- widget edit box -->
                <div class="jarviswidget-editbox">
                    <!-- This area used as dropdown edit box -->

                </div>
                <!-- end widget edit box -->

                <!-- widget content -->
                <div class="widget-body no-padding ">
                    <div class="widget-body-toolbar">
                        <div class="row">
                            <div class="col-sm-8  ">
                                <div class="btn-group">
                                    <a href="javascript:saveitem()" class="btn btn-sm btn-primary"> <i class="fa fa-floppy-o"></i> 保存 </a>
                                </div>
                                <div class="btn-group">
                                    <a href="javascript:todo(0)" class="btn btn-sm btn-primary"> <i class="fa fa-pencil-square-o"></i> 操作2 </a>
                                </div>
                                <div class="btn-group">
                                    <a href="javascript:refreshitem()" class="btn btn-sm btn-primary"> <i class="fa fa-refresh"></i> 刷新 </a>
                                </div>
                                <div class="btn-group">
                                    <a href="javascript:printitem()" class="btn btn-sm btn-primary"> <i class="fa fa-print"></i> 打印 </a>
                                </div>
                            </div>
                            <div class="col-sm-4 text-align-right">
                                <div class="btn-group">
                                    <a href="/Notifications/Index" class="btn btn-sm btn-success"> <i class="fa fa-chevron-left"></i> 返回 </a>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div class="padding-10">
                             @Html.Partial("EditForm")
                    </div>		 
                 </div>
                 <!-- end widget content -->
                 </div>
            <!-- end widget div -->

        </div>
        <!-- end widget -->


    </article>
    <!-- WIDGET END -->
  
 
</div>
 
</section>
</div>
<!-- END MAIN CONTENT -->

@section Scripts {
   
    <script type="text/javascript">
        var notificationid=@Model.Id;
	    var $editform = $('#notification_form');
        //save item
        function saveitem() {
            if ($editform.valid()) {
                var notification = $editform.serializeJSON();
                  
                var token = $('input[name="__RequestVerificationToken"]', $editform).val();
                 $.ajax({
                    type: "POST",
                    url: "/Notifications/EditAsync",
                    data: {
                        __RequestVerificationToken: token,
                        notification:notification
                    },
                    dataType: 'json',
                    contentType: 'application/x-www-form-urlencoded; charset=utf-8',
                })
                .done(function (response,textStatus, jqXHR) {
                    if (response.success) {
                        $.messager.alert("提示", "保存成功!");
                    } else {
                        $.messager.alert("错误", "保存失败!" + response.err, "error");
                    }
                    })
                .fail(function (jqXHR, textStatus, errorThrown) {
                        $.messager.alert("错误", "保存失败!" + errorThrown,"error");
                    });
            }
        }
        //功能按钮操作
        function cancelitem() {
        }
         function printitem() {
        }
        function exportexcel() {
        }
         function refreshitem() {
        }

 

     /********************************
     *
     * pageSetUp() is needed whenever you load a page.
     * It initializes and checks for all basic elements of the page
     * and makes rendering easier.
     *
     */
     //pageSetUp();
     /********************************
     *
     * pagefunction() $editform 校验规则
     *
     */
     var pagefunction = function () {
            var errorClass = 'invalid';
            var errorElement = 'em';
            $editform.validate({
                 errorClass: errorClass,
                 errorElement: errorElement,
                 highlight: function (element) {
                    $(element).parent().removeClass('state-success').addClass("state-error");
                    $(element).removeClass('valid');
                 },
                 unhighlight: function (element) {
                    $(element).parent().removeClass("state-error").addClass('state-success');
                    $(element).addClass('valid');
                 },
                // Rules for form validation
                rules: {
                                    Id:{
                            required:true,
                                                        digits: true,
                                                                                                        },
                                    Title:{
                            required:true,
                                                                                    rangelength: [0, 50],
                                                                            },
                                    Content:{
                            required:false,
                                                                                    rangelength: [0, 255],
                                                                            },
                                    Link:{
                            required:false,
                                                                                    rangelength: [0, 255],
                                                                            },
                                    Read:{
                            required:true,
                                                        digits: true,
                                                                                                        },
                                    From:{
                            required:false,
                                                                                                        },
                                    To:{
                            required:false,
                                                                                                        },
                                    Group:{
                            required:true,
                                                        digits: true,
                                                                                                        },
                                    Created:{
                            required:true,
                                                                                                                date: true,
                                                },
                                    Creator:{
                            required:false,
                                                                                                        },
                                    CreatedDate:{
                            required:false,
                                                                                                                date: true,
                                                },
                                    CreatedBy:{
                            required:false,
                                                                                    rangelength: [0, 20],
                                                                            },
                                    LastModifiedDate:{
                            required:false,
                                                                                                                date: true,
                                                },
                                    LastModifiedBy:{
                            required:false,
                                                                                    rangelength: [0, 20],
                                                                            },
                                },
                // Messages for form validation
                messages:{
                                Id:{
                                                required: 'Enter your Id',
                                        },
                               Title:{
                                                required: 'Enter your Title',
                                        },
                               Content:{
                                        },
                               Link:{
                                        },
                               Read:{
                                                required: 'Enter your Read',
                                        },
                               From:{
                                        },
                               To:{
                                        },
                               Group:{
                                                required: 'Enter your Group',
                                        },
                               Created:{
                                                required: 'Enter your Created',
                                        },
                               Creator:{
                                        },
                               CreatedDate:{
                                        },
                               CreatedBy:{
                                        },
                               LastModifiedDate:{
                                        },
                               LastModifiedBy:{
                                        },
                               },
                submitHandler: function (form) {
                    //调用保存方法
                      saveitem();
                      return false;
                    //$(form).ajaxSubmit({
                    //    success: function () {
                    //        console.log('ajaxSubmit success');
                    //   }
                    //});
                },
                // Do not change code below
                errorPlacement: function (error, element) {
                    error.insertAfter(element.parent());
                }

            });
        }
        pagefunction();



  </script>



}
 
